module key_debounce(
	input clk,
	input sys_rst, 
	input [3:0] key, 
	output reg key_value, 
	output reg  key_press_stat
);

reg [31:0] key_delay_counts;
reg  key_last_value;

parameter key_press_debounce_period  = 32'd500000; // 1000000 / 50M =  10ms

always @(posedge clk or negedge sys_rst) begin
	if (!sys_rst) begin
		key_delay_counts <= 0;
		key_last_value <= 1'b1;
	end
	else begin
		if (key != 4'b0)	begin						//有按键按下
			key_delay_counts <= key_press_debounce_period;
			key_value  <= 0;
		end
		else begin										//无按键按下
			key_delay_counts <= key_press_debounce_period;
			key_value <= 0;
		end
	end
	
end

endmodule